﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;

namespace Ccs.Core {
    public static class Extensions {
        public static TResult XmlDeserialize<TResult>(this string value) {
            TResult result;
            using (var reader = new StringReader(value)) {
                var serializer = new XmlSerializer(typeof(TResult));
                var deserializedObject = serializer.Deserialize(reader);
                result = (deserializedObject != null) ? (TResult)deserializedObject : default(TResult);
            }
            return result;
        }
    }
}
